package ${package.Entity};


<#if springdoc>
import io.swagger.v3.oas.annotations.media.Schema;
<#elseif swagger>
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
</#if>
<#if entityLombokModel>
import lombok.Data;
<#if chainModel>
import lombok.experimental.Accessors;
</#if>
</#if>
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @author ${author}
* @since ${date}
*/
<#if entityLombokModel>
@Data
<#if chainModel>
@Accessors(chain = true)
</#if>
</#if>
<#if table.convert>
@Table(name = "${schemaName}${table.name}")
</#if>
<#if springdoc>
@Schema(name = "${entity}", description = "$!{table.comment}")
<#elseif swagger>
@ApiModel(value = "${entity}对象", description = "${table.comment!}")
</#if>
<#if superEntityClass??>
public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
<#elseif activeRecord>
public class ${entity} extends Model<${entity}> {
<#elseif entitySerialVersionUID>
public class ${entity} implements Serializable {
<#else>
public class ${entity} {
</#if>
<#if entitySerialVersionUID>

    private static final long serialVersionUID = 1L;
</#if>
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
<#if field.keyFlag>
    <#assign keyPropertyName="${field.propertyName}"/>
</#if>

<#if field.comment!?length gt 0>
    <#if springdoc>
    @Schema(description = "${field.comment}")
    <#elseif swagger>
    @ApiModelProperty("${field.comment}")
    <#else>
    /**
    * ${field.comment}
    */
    </#if>
</#if>
<#if field.keyFlag>
    @Id
<#-- 主键 -->
<#--    <#if field.keyIdentityFlag>-->
<#--        @Id-->
<#--    <#elseif idType??>-->
<#--        @Id-->
<#--    <#elseif field.convert>-->
<#--        @Column(name = "${field.annotationColumnName}")-->
<#--    </#if>-->
<#-- 普通字段 -->
<#elseif field.fill??>
<#-- -----   存在字段填充设置   ----->
    <#if field.convert>
        @Column(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
    <#else>
        @Column(fill = FieldFill.${field.fill})
    </#if>
<#elseif field.convert>
    @Column(name = "${field.annotationColumnName}")
</#if>
<#-- 乐观锁注解 -->
<#if field.versionField>
    @Version
</#if>
<#-- 逻辑删除注解 -->
<#if field.logicDeleteField>
    @TableLogic
</#if>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#------------  END 字段循环遍历  ---------->
<#if !entityLombokModel>
<#list table.fields as field>
    <#if field.propertyType == "boolean">
        <#assign getprefix="is"/>
    <#else>
        <#assign getprefix="get"/>
    </#if>

    public ${field.propertyType} ${getprefix}${field.capitalName}() {
    return ${field.propertyName};
    }

    <#if chainModel>
        public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
    <#else>
        public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
    </#if>
    this.${field.propertyName} = ${field.propertyName};
    <#if chainModel>
        return this;
    </#if>
    }
</#list>
</#if>

<#function dashedToCamel(s)>
<#return s
?replace('(^_+)|(_+$)', '', 'r')
?replace('\\_+(\\w)?', ' $1', 'r')
?replace('([A-Z])', ' $1', 'r')
?capitalize
?replace(' ' , '')
?uncap_first
>
</#function>
<#if entityColumnConstant>
<#list table.fields as field>

    public static final String ${field.name?upper_case} = "${dashedToCamel(field.name)}";
</#list>
</#if>
<#if activeRecord>

@Override
public Serializable pkVal() {
<#if keyPropertyName??>
    return this.${keyPropertyName};
<#else>
    return null;
</#if>
}
</#if>
<#if !entityLombokModel>

@Override
public String toString() {
return "${entity}{" +
<#list table.fields as field>
    <#if field_index==0>
        "${field.propertyName} = " + ${field.propertyName} +
    <#else>
        ", ${field.propertyName} = " + ${field.propertyName} +
    </#if>
</#list>
"}";
}
</#if>
}
